CmdUtils.CreateCommand({
  names: ["go4es"],
  icon: "http://go4.es/favicon.ico",
  description: "Acorta la url usando go4.es",
  help: "go4es url_larga",
  author: {name: "Juan Martín", email: "nauj27@gmail.com"},
  license: "GPL",
  homepage: "http://go4.es/",
  arguments: [{role: 'object', nountype: noun_arb_text}],
  preview: function preview(pblock, args) {
    if (args.object.html == "") {
      pblock.innerHTML = "Por favor, selecciona o escribe una URL.";
    } else {
      pblock.innerHTML = "Acorta la url <b>" + args.object.html + "</b> y la copia al portapapeles.";
    }
  },
  execute: function execute(args) {
    if (args.object.html !== "") {
      var baseUrl = "http://go4.es/";
      var params = { url: args.object.html, submit: "Crear", modo: "new", api: "1" };
      jQuery.get(baseUrl, params, function(result) {
        try {
          CmdUtils.setTextSelection(result);
        } catch(e) {}
        CmdUtils.copyToClipboard(result);
        displayMessage("Aquí está. También ha sido copiada al portapapeles: " + result, this);
         
      }, "text");
    } else {
      displayMessage("No se seleccionó ninguna URL", this);
    }
  }
}); 
